package com.sdd.sg.controller;

import com.sdd.sg.api.OtherService;
import com.sdd.sg.response.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: OtherController
 * Description: 其他请求controller
 * date: 2020/7/7
 *
 * @author xugaojun
 */
@Slf4j
@RestController
@RequestMapping("/other")
public class OtherController {

    @Reference
    private OtherService otherService;


    /**
     * 随意定制请求 - foo/{} - 用于网关区分分组
     * @param id
     * @return
     */
    @GetMapping("/foo/{id}")
    public Response otherFoo(@PathVariable("id") Integer id) {
        log.info("Request -> OtherController -> foo -> :" + id);
        otherService.doAnotherThing();

        return Response.success();
    }


    /**
     * 随意定制请求 - group/{} - 用于网关区分分组
     *
     * @param groupNum
     * @return
     */
    @GetMapping("/group/{group_num}")
    public Response otherGroupOne(@PathVariable("group_num") Integer groupNum) {
        log.info("Request -> OtherController -> group -> :" + groupNum);
        otherService.doAnotherThing();

        return Response.success();
    }


    /**
     * 随意定制请求 - group/save/ - 用于网关区分分组
     *
     * @param groupNum
     * @return
     */
    @GetMapping("/group/save/{group_num}")
    public Response otherGroupSecond(@PathVariable("group_num") Integer groupNum) {
        log.info("Request -> OtherController -> group -> :" + groupNum);
        otherService.doAnotherThing();

        return Response.success();
    }


}
